const { mfutil } = getApp();
Component({
  mixins: [],
  data: {
    boxShow: false,
    topNum: 0,
    tagArray: [],
    logArray: [],
    tabActiveIndex: 1
  },
  props: {},
  didMount() {
    let num = my.getSystemInfoSync().screenHeight;
    this.setData({
      topNum: num,
      tabActiveIndex: 1
    });
    this._vanimation = my.createAnimation({
      duration: 500,
      timeFunction: "ease-in-out",
      delay: 0,
    });
    this.get(0);
  },
  didUpdate() { },
  didUnmount() { },
  methods: {
    //  获取日志
    async get(index) {
      let res = await mfutil.logger.get();
      this.setData({
        tagArray: res,
        logArray: res[index].logArray
      })
    },
    boxAnime() {
      if (this.data.boxShow) {
        this.animeHiddenBox();
      } else {
        this.animeShowBox();
      }
      this.data.boxShow = !this.data.boxShow;
    },
    // 弹窗展示
    animeShowBox() {
      this._vanimation.top(0).step()
      this.setData({ animation: this._vanimation.export() });
      this.get(0);
    },
    // 弹窗隐藏
    animeHiddenBox() {
      let _device = my.getSystemInfoSync();
      this._vanimation.top(_device.screenHeight).step()
      this.setData({
        animation: this._vanimation.export(),
        tabActiveIndex: 1
      });
    },
    //  tab切换
    tabSwitch(e) {
      const { currentTarget: { dataset: { index } } } = e;
      console.log(index)
      this.setData({
        tabActiveIndex: index
      });
      this.get(index - 1);
    }
  },
});
